package com.wuchao.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuchao.mapper.UsersMapper;
import com.wuchao.pojo.Users;
import com.wuchao.service.UsersService;
import com.wuchao.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author wuchao66
 * @Date 2022/9/19 17:00
 * @PackageName:com.wuchao.service.serviceImpl
 * @ClassName: UsersServiceImpl
 * @Description: TODO
 * @Param
 * @Version 1.0
 */
@Service
public class UsersServiceImpl implements UsersService {//包含的是mapper的方法
  /*private UsersMapper mapper  =
          Utils.getSqlSession().getMapper(UsersMapper .class);*/
    //spring ioc 自动注入
    @Resource //自动注入
    private UsersMapper mapper;
    @Override
    public List<Users> findUsersByNameConcat(String name) {
        return mapper.findUsersByNameConcat(name);
    }

    @Override
    public int insertUsersByUsers(Users users) {
        return mapper.insertUsersByUsers(users);
    }

    @Override
    public List<Users> findUsersByMapNameConcat(Map map) {
        return mapper.findUsersByMapNameConcat(map);
    }

    @Override
    public List<Users> findInfo() {
        return mapper.findInfo();
    }

    @Override
    public List<Users> findUsersAndManByManNameConcat(String name) {
        return mapper.findUsersAndManByManNameConcat(name);
    }

    @Override
    public List<Users> selectUsersAndManByManNameConcat(String name) {
        return mapper.selectUsersAndManByManNameConcat(name);
    }

    @Override
    public List<Users> selectfindUsersAndManByManNameConcat(String name) {
        return mapper.selectfindUsersAndManByManNameConcat(name);
    }

    @Override
    public PageInfo<Users> findUsersAndManBynameConcatByPage(int currentPage, int pageSize, String name) {
        //分页对象一定要写在第一位
        PageHelper.startPage(currentPage, pageSize);//开始分页
        List<Users> list = mapper.findUsersAndManBynameConcatByPage(name);
        return new PageInfo<Users>(list);
    }

    @Override
    public PageInfo<Users> findUsersAndTypeBynameConcatByPage(int currentPage, int pageSize, String name) {
        //分页对象大头
        PageHelper.startPage(currentPage, pageSize);
        List<Users> list = mapper.findUsersAndTypeBynameConcatByPage(name);
        return new PageInfo<Users>(list);
    }
}
